package com.jia.service;

import com.jia.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

// 降级
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public DeptClientService create(Throwable cause) {
        return new DeptClientService() {
            @Override
            public int deleteDept(Long deptno) {
                return 0;
            }

            @Override
            public List<Dept> selectAll() {
                return null;
            }

            @Override
            public Dept selectById(Long deptno) {
                return new Dept()
                        .setDeptno(deptno)
                        .setDname("没有对应的信息，这个服务关闭了")
                        .setDbSource("no DataSource");
            }
        };
    }
}
